# Contributor: Bhushan Shah <bshah@kde.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=libphonenumber
pkgver=8.13.26
pkgrel=0
pkgdesc="Library for parsing, formatting, and validating international phone numbers."
url="https://github.com/google/libphonenumber"
arch="all"
license="Apache-2.0"
depends_dev="
	abseil-cpp-dev
	icu-dev
	protobuf-dev
	"
makedepends="$depends_dev
	cmake
	gtest-dev
	ninja
	"
checkdepends="icu-data-full"
subpackages="$pkgname-static libgeocoding $pkgname-dev"
source="https://github.com/google/libphonenumber/archive/v$pkgver/libphonenumber-v$pkgver.tar.gz
	system-abseil.patch
	"

build() {
	cd cpp
	LDFLAGS="$LDFLAGS -Wl,--copy-dt-needed-entries" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DREGENERATE_METADATA=OFF \
		-DUSE_BOOST=OFF \
		-DUSE_STDMUTEX=ON
	cmake --build build
}

check() {
	cd cpp
	./build/libphonenumber_test
}

package() {
	cd cpp
	DESTDIR="$pkgdir" cmake --install build
}

libgeocoding() {
	amove usr/lib/libgeocoding.so.*
}

sha512sums="
cecf3981659df651e66987f19ebbe12a39c9626a965e986d0d9507616e28d3f9e9de8e5d3f87e0e8cc1dc19e1907d62689063fc49d6340d7bd61278e27e69a7f  libphonenumber-v8.13.26.tar.gz
03c1eb32208a868bcacf92eb42b1f3f009bcc898fa6446594a3e79baadbef5fb53bbe829adfb7d0c8ebebdd37898c6686ff837320d258cd47ef5de7a6bf341bc  system-abseil.patch
"
